package com.ruoyi.wechat.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wechat.domain.CEvaluate;
import com.ruoyi.wechat.service.ICEvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 评价Controller
 * 
 * @author ruoyi
 * @date 2024-12-05
 */
@RestController
@RequestMapping("/camp/evaluate")
public class CEvaluateController extends BaseController
{
    @Autowired
    private ICEvaluateService cEvaluateService;

    /**
     * 查询评价列表
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:list')")
    @GetMapping("/list")
    public TableDataInfo list(CEvaluate cEvaluate)
    {
        startPage();
        List<CEvaluate> list = cEvaluateService.selectCEvaluateList(cEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出评价列表
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:export')")
    @Log(title = "评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CEvaluate cEvaluate)
    {
        List<CEvaluate> list = cEvaluateService.selectCEvaluateList(cEvaluate);
        ExcelUtil<CEvaluate> util = new ExcelUtil<CEvaluate>(CEvaluate.class);
        util.exportExcel(response, list, "评价数据");
    }

    /**
     * 获取评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:query')")
    @GetMapping(value = "/{evaluateId}")
    public AjaxResult getInfo(@PathVariable("evaluateId") String evaluateId)
    {
        return success(cEvaluateService.selectCEvaluateByEvaluateId(evaluateId));
    }

    /**
     * 新增评价
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:add')")
    @Log(title = "评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CEvaluate cEvaluate)
    {
        return toAjax(cEvaluateService.insertCEvaluate(cEvaluate));
    }

    /**
     * 修改评价
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:edit')")
    @Log(title = "评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CEvaluate cEvaluate)
    {
        return toAjax(cEvaluateService.updateCEvaluate(cEvaluate));
    }

    /**
     * 删除评价
     */
    @PreAuthorize("@ss.hasPermi('camp:evaluate:remove')")
    @Log(title = "评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaluateIds}")
    public AjaxResult remove(@PathVariable String[] evaluateIds)
    {
        return toAjax(cEvaluateService.deleteCEvaluateByEvaluateIds(evaluateIds));
    }
}
